USE SBM
GO

DELETE FROM dbo.DEPOSIT
DELETE FROM dbo.WITHDRAW
DELETE FROM dbo.DAILYREPORTDETAIL
DELETE FROM dbo.DAILYREPORT
DELETE FROM dbo.MONTHLYREPORTDETAIL
DELETE FROM dbo.MONTHLYREPORT
DELETE FROM dbo.SAVINGBOOK
DELETE from dbo.SAVINGTYPE
DELETE FROM dbo.CUSTOMER
DELETE FROM dbo.PARAMETER

USE SBM
GO
INSERT INTO dbo.PARAMETER(MinOfDeposit, MinOfWithdraw, MinOfDepositPeriod, InterestFreePeriod)
	VALUES(200000, 100000, 15, 5)

INSERT INTO dbo.SAVINGTYPE(TypeID, TypeName, Term, InterestRate, AllowSave, AllowWithdraw)
	VALUES('','Khong ky han', -1, 0.005, 1, 1)
INSERT INTO dbo.SAVINGTYPE(TypeID, TypeName, Term, InterestRate, AllowSave, AllowWithdraw)
	VALUES('','Ky han 3 thang', 3, 0.0075, 0, 0)

INSERT INTO dbo.CUSTOMER(CustomerID, FullName, IDNumber, HomeAddress, Email, Phone)
	VALUES('', N'Do Ngoc Sam', '1234567890', 'qwertyui-sdfghjk-cb', 'asdfgh@sdfgh.com', '12345678554')
INSERT INTO dbo.CUSTOMER(CustomerID, FullName, IDNumber, HomeAddress, Email, Phone)
	VALUES('', N'Tran Trong Nhan', '1234567890', 'qwertyui-sdfghjk-cb', 'asdfgh@sdfgh.com', '12345678554')
INSERT INTO dbo.CUSTOMER(CustomerID, FullName, IDNumber, HomeAddress, Email, Phone)
	VALUES('', N'Doan Minh Tien', '1234567890', 'qwertyui-sdfghjk-cb', 'asdfgh@sdfgh.com', '12345678554')
INSERT INTO dbo.CUSTOMER(CustomerID, FullName, IDNumber, HomeAddress, Email, Phone)
	VALUES('', N'Nguyen Phi Hung', '1234567890', 'qwertyui-sdfghjk-cb', 'asdfgh@sdfgh.com', '12345678554')

INSERT INTO dbo.SAVINGBOOK(BookID, CustomerID, TypeID, OpeningDate, InterestStartingDate, AccountBalance, SBStatus)
	VALUES('', 'CT00000002', 'TD00000002', '01/01/2000', '',100,'')
INSERT INTO dbo.SAVINGBOOK(BookID, CustomerID, TypeID, OpeningDate, InterestStartingDate, AccountBalance, SBStatus)
	VALUES('', 'CT00000001', 'TD00000002','02/01/2001', '', '','')

INSERT INTO dbo.DEPOSIT (DepositID, DepositingDate, CustomerName, BeneficiaryName, BookID, AmountOfMoney)
	VALUES('', '01/01/2000', N'Tran Trong Nhan', N'Tran Trong Nhan', 'PS00000001', 1000000)
INSERT INTO dbo.DEPOSIT (DepositID, DepositingDate, CustomerName, BeneficiaryName, BookID, AmountOfMoney)
	VALUES('', '01/01/2001', N'Tran Trong Nhan', N'Tran Trong Nhan', 'PS00000001', 1000000)
INSERT INTO dbo.DEPOSIT (DepositID, DepositingDate, CustomerName, BeneficiaryName, BookID, AmountOfMoney)
	VALUES('', '01/01/2009', N'Tran Trong Nhan', N'Tran Trong Nhan', 'PS00000001', 1000000)
INSERT INTO dbo.DEPOSIT (DepositID, DepositingDate, CustomerName, BeneficiaryName, BookID, AmountOfMoney)
	VALUES('', '01/01/2009', N'Tran Trong Nhan', N'Tran Trong Nhan', 'PS00000001', 500000)

INSERT INTO dbo.WITHDRAW(WithDrawID, WithDrawingDate, BookID, CustomerName, IDNumber, AmountOfMoney)
	VALUES('', '01/01/2009', 'PS00000001', N'Tran Trong Nhan', N'1234567890', 500000)
INSERT INTO dbo.WITHDRAW(WithDrawID, WithDrawingDate, BookID, CustomerName, IDNumber, AmountOfMoney)
	VALUES('', '01/09/2009', 'PS00000001', N'Tran Trong Nhan', N'1234567890', 200000)
INSERT INTO dbo.WITHDRAW(WithDrawID, WithDrawingDate, BookID, CustomerName, IDNumber, AmountOfMoney)
	VALUES('', '01/09/2009', 'PS00000001', N'Tran Trong Nhan', N'1234567890', 100000)

select * from dbo.SAVINGTYPE
select * FROM dbo.CUSTOMER
select * FROM dbo.SAVINGBOOK
select * from dbo.deposit
select * from dbo.withdraw
select * from dbo.dailyreport
select * from dbo.dailyreportdetail
select * from dbo.monthlyreport
select * from dbo.monthlyreportdetail
select * from dbo.parameter

DELETE dbo.CUSTOMER where CustomerID='CT00000004'

DECLARE @M bigint
EXEC @M = dbo.PROC_Balance 'PS00000001', '01/01/2000'
SELECT @M
go
select *
from DEPOSIT
go
select *
from SAVINGBOOK
go
select *
from WITHDRAW
go 
insert into DEPOSIT
values('','','','','PS00000006',1000000)
go
insert into WITHDRAW
values('','','PS00000006','','',500000)